<template>
  <div class="hotMv">
    <ul>
      <li v-for="item in mvList" :key="item.id">
        <router-link :to="'/recommend/mv?id=' + item.id">
          <div class="img">
            <img :src="item.cover" />
            <span class="playCount">{{ item.playCount | formatNum }}</span>
          </div>
          <p>{{ item.name }} - {{ item.artistName }}</p>
        </router-link>
      </li>
    </ul>
  </div>
</template>
<script>
export default {
  props: {
    mvList: Array,
  },
  filters: {
    formatNum(value) {
      return value > 100000000
        ? (value / 100000000).toFixed(0) + "亿"
        : value > 10000
        ? (value / 10000).toFixed(1).replace(/\.0$/, "") + "万"
        : value;
    },
  },
};
</script>

<style lang="less" scoped>
.hotMv {
  ul {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    padding-top: 5px;
    li {
      width: 48%;
      &:not(:nth-last-of-type(-n + 2)) {
        margin-bottom: 10px;
      }
      a {
        color: inherit;
        .img {
          position: relative;
          border-radius: 1.867vw;
          overflow: hidden;
          img {
            width: 100%;
          }
          .playCount {
            position: absolute;
            right: 5px;
            top: 2px;
            z-index: 3;
            padding-left: 15px;
            color: #fff;
            font-size: 12px;
            text-shadow: 1px 0 0 rgba(0, 0, 0, 0.15);
            background-position: 0;
            background-size: 11px 10px;
            background-repeat: no-repeat;
            background-image: url(../assets/play2.png);
          }
          &::after {
            content: " ";
            position: absolute;
            left: 0;
            top: 0;
            width: 100%;
            height: 20px;
            z-index: 2;
            background-image: -webkit-linear-gradient(
              top,
              rgba(0, 0, 0, 0.2),
              rgba(0, 0, 0, 0)
            );
          }

          background-image: linear-gradient(
            180deg,
            rgba(0, 0, 0, 0.2),
            rgba(0, 0, 0, 0)
          );
        }
        p {
          display: -webkit-box;
          -webkit-line-clamp: 2;
          -webkit-box-orient: vertical;
          overflow: hidden;
          padding: 6px 2px 0 6px;
          min-height: 30px;
          line-height: 1.2;
          font-size: 13px;
          word-break: break-all;
        }
      }
    }
  }
}
</style>